#include "mediacoreimpl.h"
#include "DemuxerTask.h"
#include "openslsoundtask.h"
MediaCoreImpl::MediaCoreImpl():
    m_oDemuxerTask(0),
    m_oRtmpStreamImpl(0)
{
    m_oDemuxerTask      = new DemuxerTask;
    m_oSoundTask        = new OpenSLSoundTask;
}

MediaCoreImpl::~MediaCoreImpl()
{
    if(m_oDemuxerTask)
        delete m_oDemuxerTask;

    if(m_oSoundTask)
        delete m_oSoundTask;
}

bool MediaCoreImpl::Start(const char * url, MediaImagehandler *handler)
{
    if(m_oDemuxerTask)
    {
        m_oSoundTask->Init(m_oDemuxerTask);
        m_oSoundTask->activate();
        if(m_oDemuxerTask->open(url,m_oSoundTask,handler) == false)
        {
            m_oDemuxerTask->close();
            return false;
        }
        m_oDemuxerTask->activate();

    }
    return true;
}

void MediaCoreImpl::Stop()
{
    if(m_oDemuxerTask)
        m_oDemuxerTask->close();    //解码播放任务停止

    if(m_oSoundTask)
        m_oSoundTask->close();//音频开关任务停止
}

